Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement redemptions with a proxy for redemption integrations #814

Merged
merged 6 commits into from
Jun 11, 2024

Conversation

nkuba
Copy link
Member

@nkuba nkuba commented Jun 4, 2024

In this PR we introduce a RedeemerProxy interface that can be used by integrators to route tBTC redemption through the tBTC Bridge.

An example of the integrator is Acre's BitcoinRedeemer contract that requires the redemption data to handle stBTC -> tBTC -> Bitcoin conversion in one transaction.

When redeeming tBTC the challenge is to assemble redemption data to contain valid wallet UTXO and other data in the format expected by the Bridge.

It is expected that the integrator will implement RedeemerProxy interface by exposing two functions:

  • redeemerAddress(): ChainIdentifier - that will return the Ethereum address to which the tBTC balance will be assigned in case of problems with redemption,
  • requestRedemption(redemptionData: Hex): Promise<Hex> - a callback function that will be called with assembled redemptionData to proceed with a custom integrator's logic.

The integrator should use the requestRedemptionWithProxy function to execute the redemption.

@nkuba nkuba requested a review from lukasz-zimnoch June 4, 2024 09:57
@nkuba nkuba self-assigned this Jun 4, 2024
@nkuba nkuba added the 🔌 typescript TypeScript library label Jun 4, 2024
@nkuba nkuba marked this pull request as draft June 4, 2024 09:58
nkuba added a commit to thesis/acre that referenced this pull request Jun 7, 2024
This branch expects two dependencies changes that are not yet merged:
- @keep-network/tbtc-v2.ts: keep-network/tbtc-v2#814
- @orangekit/sdk: thesis/orangekit#83
@nkuba nkuba mentioned this pull request Jun 7, 2024
nkuba added a commit to thesis/acre that referenced this pull request Jun 7, 2024
This branch expects two dependencies changes that are not yet merged:
- @keep-network/tbtc-v2.ts: keep-network/tbtc-v2#814
- @orangekit/sdk: thesis/orangekit#83
nkuba added a commit to thesis/acre that referenced this pull request Jun 7, 2024
This branch expects two dependencies changes that are not yet merged:
- @keep-network/tbtc-v2.ts: keep-network/tbtc-v2#814
- @orangekit/sdk: thesis/orangekit#83
@nkuba nkuba marked this pull request as ready for review June 11, 2024 14:03
@nkuba nkuba changed the title Expose function to build redemption data Implement redemptions with a proxy for redemption integrations Jun 11, 2024
In this PR we expose a function to build redemption data in the raw bytes
format as expected by the tBTC Bridge. This function can be used by the
custom integrator contracts to build the redemption data required to request
tBTC redemption.

Example of the integrator is Acre's [BitcoinRedeemer contract](https://github.com/thesis/acre/blob/main/solidity/contracts/BitcoinRedeemer.sol)
that requires the redemption data to handle stBTC -> tBTC -> Bitcoin
conversion in one transaction.
This commit introduces a new redemption flow that uses a proxy implementation
to request the redemption of tBTC. It gives flexibility to the external
integrators to use the redemption data required by the tBTC protocol to
request the redemption of tBTC in their contracts.
It can also be used to relay the transaction submission with external
relayer (e.g. Gelato).
The function was unintentionally changed to public in the previous commit.
Here we revert the change back.
Added tests to cover requestRedemptionWithProxy function in redemptions service.
Extracted common setup to a function shared by two tests.
@nkuba nkuba force-pushed the expose-redemption-data-build branch from ebc76fb to 548332d Compare June 11, 2024 14:50
@lukasz-zimnoch lukasz-zimnoch merged commit 6e5e75b into main Jun 11, 2024
38 checks passed
@lukasz-zimnoch lukasz-zimnoch deleted the expose-redemption-data-build branch June 11, 2024 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔌 typescript TypeScript library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants